package ar.edu.caece.pl.asem.model.impl.treeelements;

import ar.edu.caece.pl.asem.label.LabelGenerator;

public class Sino extends AbstractElement {

	public Sino() {
		this.label = "ELSE";
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (!(obj instanceof Sino))
			return false;
		Sino other = (Sino) obj;
		if (label == null) {
			if (other.label != null)
				return false;
		} else if (!label.equals(other.label))
			return false;
		return true;
	}

	@Override
	public void generateASMCode() {
		StringBuffer sb = new StringBuffer();
		String startLabel = LabelGenerator.getInstance().generateLabel();
		// Codigo de adentro del <ELSE>
		this.getChildren().get(0).generateASMCode();
		sb.append(this.getChildren().get(0).code);
		sb.append(startLabel + ": \n");
		this.code = sb.toString();
	}

}
